/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.beiing.leafchartdemo;


import com.beiing.leafchat.bean.Line;
import com.beiing.leafchat.bean.PointValue;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
import ohos.agp.colors.RgbPalette;
import ohos.agp.components.Attr;
import ohos.agp.components.AttrSet;
import ohos.agp.utils.Color;
import org.junit.BeforeClass;
import org.junit.Test;

import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class ExampleOhosTest {
     private static Line line;
    @Test
    public void testBundleName() {
        final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName();
        assertEquals("com.beiing.leafchartdemo", actualBundleName);
    }

    @BeforeClass
    public static void set(){
        List<PointValue> pointValues = new ArrayList<>();
        SecureRandom random = new SecureRandom();
        for (int i = 1; i <= 12; i++) {
            PointValue pointValue = new PointValue();
            pointValue.setX( (i - 1) / 11f);
            int var = (int) (random.nextFloat() * 100);
            pointValue.setLabel(String.valueOf(var));
            pointValue.setY(var / 100f);
            pointValues.add(pointValue);
        }
        line = new Line(pointValues);
        line.setLineColor(Color.RED.getValue())
                .setLineWidth(3)
                .setPointColor(Color.YELLOW.getValue())
                .setCubic(true)
                .setPointRadius(3)
                .setFill(false)
                .setHasLabels(true)
                .setLabelColor(Color.BLACK.getValue());

    }

    @Test
    public void getLineColor(){
        assertTrue(Color.RED.getValue()==line.getLineColor());
    }

    @Test
    public void getLineWidth(){
        assertTrue(3==line.getLineWidth());
    }

    @Test
    public void isCubic(){
        assertTrue(line.isCubic());
    }

    @Test
    public void getPointRadius(){
        assertTrue(3==line.getPointRadius());
    }

    @Test
    public void isHasLabels(){
        assertTrue(line.isHasLabels());
    }

    @Test
    public void getLabelColor(){
        assertTrue(Color.BLACK.getValue()==line.getLabelColor());
    }

}